package com.carcenter.order.mapper;

import com.carcenter.order.entity.AppointmentDetail;
import com.carcenter.order.entity.AppointmentMaster;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author car
 * @since 2025-07-16
 */
@Mapper
public interface AppointmentMasterMapper extends BaseMapper<AppointmentMaster> {



    @Select("SELECT * from appointment_detail d " +
            "LEFT OUTER JOIN appointment_process p ON d.appointment_id = p.appointment_id " +
            "LEFT OUTER JOIN appointment_master m ON p.appointment_id = m.id " +
            "WHERE m.start_time >= #{firstDay} AND m.end_time <= #{lastDay} " +
            "AND m.store_id = #{storeId} " +
            "AND p.appointment_status = '已完成'")
    List<AppointmentDetail> selectMonthAppointmentDetail(@Param("storeId") Integer storeId,@Param("firstDay") LocalDateTime firstDay,@Param("lastDay") LocalDateTime lastDay);
}
